home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
jhtools.exe
/
REGHELP.TXT
< prev
next >
Wrap
Text File
|
1992-02-08
|
33KB
|
1,334 lines
*
*
*
* *
* * *
*
* *
* * *
*
#
##### # # # ####
# # # #
# * ##### ### *
* # # # #
#### # # * ####
*
*
*
*
* * *
*
#### ### #### # # #### ###
# # # # # # # # # #
# * ### # # # # # ### #### *
* # # # # # # # # # # #
#### # #### # *# #### # #
*
* *
* * *
*
* *
* *
*
*
##### ##### ##### # ####*
* # # # # # # #
* # # # # # #* ###
# # # # # # #
# ##### ##### #### ###
*
* *
*
* * *
* VERSION 1.0
Welcome to the JH'S C POWER TOOLS sharewhare manual. This
manual is mainly designed for those c programers who wish to
understand how to use the libarary's functions. If you want to
know how the programs work or why they made the way they were you
will need to get the expanded manual that comes with the registered
version.
The disks that were mailed to you should include the
following:
READx.EXE
MENUx.LIB
UTLx.LIB
MOUSx.LIB
KEYx.H
MENx.H
SHAPEx.H
REGHELPx.TXT (This file)
The x by each name is the version number.
If you did not receive any of the following please contact me
via my E-MAIL number or by regular mail and I will get a
replacement copy to you ASAP.
Thank you for you support.
MENUx.C HELP SECTION:
This is the menu help section. In this section I will
go through each function one by one and explain how to call each
function and what it returns.
Before I start with the functions I am going to go over
some basics that you will need to know in order to understand
the functions.
POINTERS:
The usefulness of pointers come from the fact that in
all C functions varibles are passed by value and since
functions only recieve local varibles it can not change the
original values that the varible represents. Pointers make
this possible. Another use for pointers is the manipulating
of an array by moving the pointers to its elements.
A pointer is a varible that holds the address of an
object (it "points" to the address in memory where the
varible is stored.)
DEFINATION OF POINTERS:
All C varibles need to be defined and pointers are no
different. Below are some examples of how to declare
pointers:
int *ptr; /* This is a pointer to an interger */
char *buffer; /* This is a pointer to a character */
char *buffer[]={
" This is a pointer ",
" to an array of ",
" characters ",
""};
In the last case:
*buffer[1]=this is a pointer
*buffer[2]=to an array of
*buffer[3]=characters
Any normal varible type that can be defined can also be
defined as a pointer.
HOW TO USE POINTERS:
Example:
1) int x=1,y=2,z=3;
2) int *xx,*yy,*zz;
3) xx=&x;
4) yy=&y;
5) zz=&z;
6) printf(" x= %d\n y= %d\n z= %d\n",x,y,z);
7) printf(" *xx=%d\n*yy=%d\n*zz=%d\n",*xx,*yy,*zz);
8) printf(" &x=%u\n &y=%u\n &z=%u\n",&x,&y,&z);
9) printf(" xx=%u\n yy=%u\n zz=%u\n",xx,yy,zz);
Alright you know that a pointer "points" to the address where
a varible is stored. Right, good now here is where we start
to get tricky. The '&' operater means "the address of" and *
means "what is pointed to by."
So in line 3 you would want to read it as "xx equals the
address of x." There for you now know that the pointer xx is
pointing to the varible x. If you follow that reasoning you
could come up with the conclusion that in line 7 where we are
printing out what is being pointed to by xx it should be the
same value as x. Try to figure out what will be printed out
before you run this program and then see if you are right.
If so continue on.
VARIBLES AND FUNCTIONS:
Earlier we stated the fact that we use pointers to
change the value of a varible in a function that was passed
to it. With out pointers you could only return one varible
from a function but with pointers you can change many
varibles and have them stay changed when you leave the
function. This section will show you how it is done.
Example:
1) main() {
2) int x=0,y=0;
3) printf("x=%d/ny=%d",x,y);
4) change(&x,&y);
5) printf("x=%d\ny=%d",x,y);
6) }
7) change(int *x,int *y) {
8) *x=3;
9) *y=5; }
This program will change the varible x and y to 3 and 5
respectively and they will remain changed when they return to
the main function. Now we can return more than one varible
from a function.
When you pass an array of pointers to a function you
don't have to pass each element of the array you can pass
just the name. For example if you have an array of intergers
defined as int *num={ 5, 10, 15, 20 } when you call the
function you can call it like this 'function(num)' and the
whole array will be passed.
MISC POINTER FUNCTIONS:
Say for example you have two pointers and you want to
point to the same address:
pointer1=pointer2
and it is done.
Say you have a pointer to an array and you want to go to
the next element in the array:
pointer++
and it is done. Maybe you want to go to the previous
element:
pointer--
and it is done.
POINTERS AND MY LIBARIES:
I used a lot of pointers in my menu libary mainly
because I am using direct memory addressing and it make it a
lot easier to use pointer rather than varibles. I also tend
to wnat to pass more than one varible back the the parent
function. You have a basic understanding of pointers now so
you should be able to understand must of what I am doing with
them. For more infomation you can look an almost any C
manual and they will give you about a ten to fifteen page
lession on pointers. If you still have question fill free to
contact me.
INTERRUPTS:
Interrupts are a neat and somtimes tricky part of your
DOS and BIOS enviroment. If you are not sure what they are
and how they work pick up almost any DOS reference manual and
turn to the interrupt section and start reading you can find
a LOT of interesting things that you can put in your programs
that you throught were impossible to do.
An interrupt is a signal to the processor from a program
that tells the processor to temporarily suspend the current
function that the CPU is working on and proform another task
defined by the interrupt function number. Each interrupt
function has a section of coded called an interrupt service
routine that is memory resident just like any TSR program.
So each time your program call an inter